﻿using System;
using Epm.AppLogic.Framework;
using msBsc.Xsd.DataTds;
using System.Data;
using msBsc.Cls;

namespace msBsc.AppLogic.DataAlc
{
    /// <summary>
    /// 用户基本信息
    /// </summary>
    public class CBizCustomerBaseInfo : CustBizObject
    {
        private CDmDjkCustomerBaseInfo m_CDmDjkCustomerBaseInfo = new CDmDjkCustomerBaseInfo();
        private CDmDjkCustomerBaseInfo oDmDjkCustomerBaseInfo
        {
            get { return m_CDmDjkCustomerBaseInfo; }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public CBizCustomerBaseInfo()
            : base()
        {
            this.DataObj = new CDbAccess();
            this.DataObj.Init(this.m_CDmDjkCustomerBaseInfo.DJK_CUSTOMER_BASEINFO);
            this.TableName = this.DataObj.TableName;
            this.DataObj.KeyField = this.DataObj.Fields["CUSTOMER_BASEINFO_ID"];
        }

        /// <summary>
        /// 新增记录前的处理
        /// </summary>
        /// <param name="drw">新增数据行</param>
        /// <returns>true/false</returns>
        /// <remarks>
        /// 生成ID值
        /// </remarks>
        protected override bool BeforeRowAdded(DataRow drw)
        {
            if (drw[this.KeyFieldName].ToString().Length < 10)
            {
                drw[this.KeyFieldName] = this.DataObj.NewID();
            }
            return true;
        }

        /// <summary>
        /// 记录修改前检验
        /// </summary>
        /// <param name="drw">当前记录</param>
        /// <returns>>校验合法，返回值为true,否则返回false</returns>
        /// <remarks>
        /// ID不允许修改,并把此修改操作记录到BSE_MODIFY_HISTORY表中
        /// </remarks>
        protected override bool BeforeRowModified(DataRow drw)
        {
            //ID不容许修改
            if (drw[this.KeyFieldName].ToString() != drw[this.KeyFieldName, DataRowVersion.Original].ToString())
            {
                Exception e = new Exception(this.TableName + "表的主键" + this.KeyFieldName + "字段不允许被修改");
                throw e;
            }
            #region 格式验证
            if (!string.IsNullOrEmpty(drw["CUSTOMER_BASEINFO_EMAIL"].ToString()) && CommValiCollection.IsEmail(drw["CUSTOMER_BASEINFO_EMAIL"].ToString()) && drw["CUSTOMER_BASEINFO_EMAIL"].ToString().Length > 50)
            {
                Exception e = new Exception("用户邮箱格式错误");
                throw e;
            }
            if (!string.IsNullOrEmpty(drw["CUSTOMER_BASEINFO_QQ"].ToString()) && CommValiCollection.IsQQ(drw["CUSTOMER_BASEINFO_QQ"].ToString()) && drw["CUSTOMER_BASEINFO_QQ"].ToString().Length > 15)
            {
                Exception e = new Exception("QQ格式错误");
                throw e;
            }
            if (!string.IsNullOrEmpty(drw["CUSTOMER_BASEINFO_BIRTH"].ToString()) && CommValiCollection.IsDate(drw["CUSTOMER_BASEINFO_BIRTH"].ToString()))
            {
                Exception e = new Exception("生日格式错误");
                throw e;
            }
            if ((drw["CUSTOMER_BASEINFO_GENDER"].ToString().ToUpper() != "M") && (drw["CUSTOMER_BASEINFO_GENDER"].ToString().ToUpper() != "F"))
            {
                Exception e = new Exception("用户性别格式错误");
                throw e;
            }
            if (!string.IsNullOrEmpty(drw["CUSTOMER_BASEINFO_MOBILE"].ToString()) && drw["CUSTOMER_BASEINFO_MOBILE"].ToString().Length > 20)
            {
                Exception e = new Exception("移动电话格式错误");
                throw e;
            }
            if (!string.IsNullOrEmpty(drw["CUSTOMER_BASEINFO_PHONE"].ToString()) && drw["CUSTOMER_BASEINFO_PHONE"].ToString().Length > 16)
            {
                Exception e = new Exception("固定电话格式错误");
                throw e;
            }
            if (!string.IsNullOrEmpty(drw["CUSTOMER_WECHAT_NO"].ToString()) && drw["CUSTOMER_WECHAT_NO"].ToString().Length > 30)
            {
                Exception e = new Exception("微信格式错误");
                throw e;
            }
            #endregion
            return true;
        }
        protected override bool BeforeRowDeletedR(DataRow drw)
        {
            //using (msBsc.AppLogic.DataAlc.CBizShpPageColumn objtem = new CBizShpPageColumn())
            //{
            //    DataSet ds = objtem.SelectByPageNo(this.GetRowStr(drw, KeyFieldName));
            //    for (int i = ds.Tables[0].Rows.Count - 1; i >= 0; i--)
            //    {
            //        ds.Tables[0].Rows[i].Delete();
            //    }
            //    objtem.Update(ds);
            //} 
            return true;
        }

        protected override bool AfterRowAdded(DataRow drw)
        {
            return true;
        }

        protected override bool AfterRowModified(DataRow drw)
        {
            return true;
        }

        protected override bool AfterRowDeletedR(DataRow drw)
        {
            return true;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="custId"></param>
        /// <param name="custAccount"></param>
        public void AddCustomerBaseInfo(string custId, string custAccount)
        {
            DataSet ds = new CDmDjkCustomerBaseInfo();
            DataRow dr = ds.Tables[0].NewRow();
            dr["CUSTOMER_BASEINFO_EMAIL"] = custAccount;
            dr["CUSTOMER_BASEINFO_ID"] = custId;
            dr["BASEINFO_IS_DELETED"] = 0;
            dr["BASEINFO_IS_DISPLAY"] = 1;
            dr["CUSTOMER_BASEINFO_GENDER"] = "M";

            ds.Tables[0].Rows.Add(dr);
            this.Update(ds);
        }
        /// <summary>
        /// 区域代理 添加
        /// </summary>
        /// <param name="cusid">用户ID</param>
        /// <param name="identityCard">身份证 照片</param>
        /// <param name="realName">真实姓名</param>
        /// <param name="credentialsNo">身份证号码</param>
        /// <param name="sex">性别</param>
        /// <param name="birth">生日</param>
        /// <param name="distinid">代理 地区（地区）</param>
        /// <param name="cityid">代理 地区（城市）</param>
        /// <param name="countryid">代理 地区（国）</param>
        /// <param name="mobile">移动电话</param>
        /// <param name="phone">固定电话</param>
        /// <param name="qq">qq</param>
        /// <param name="wechat">微信</param>
        /// <param name="bankType">银行类型</param>
        /// <param name="bankAccount">银行帐号</param>
        /// <param name="credentialsType">证件类型</param>
        /// <returns>string[]</returns>
        /// Author:蒲崇彬
        /// Creation date:2015-8-31 17:40
        public string[] AddCustomerBaseInfo(string cusid, string identityCard, string realName, string credentialsNo, string sex, string birth, string distinid, string cityid, string countryid, string mobile, string phone, string qq, string wechat, string bankType, string bankAccount, string credentialsType)
        {
            if (!string.IsNullOrEmpty(qq) && !CommValiCollection.IsQQ(qq))
            {
                return new string[] { "FALSE", "QQ只能是以1-9开头的4至12位数字" };
            }
            if (!string.IsNullOrEmpty(birth) && !CommValiCollection.IsDate(birth))
            {
                return new string[] { "FALSE", "生日日期格式错误" };
            }


            //添加区域 代理基本信息
            DataSet ds = new CDmDjkCustomerBaseInfo();
            DataRow dr = ds.Tables[0].NewRow();
            dr["CUSTOMER_BASEINFO_GENDER"] = sex;

            if (!string.IsNullOrEmpty(birth))
            {
                dr["CUSTOMER_BASEINFO_BIRTH"] = birth;
            }
            else
            {
                dr["CUSTOMER_BASEINFO_BIRTH"] = DBNull.Value;
            }
            dr["CUSTOMER_BASEINFO_ID"] = cusid;
            dr["AGENT_DISTINATION_ID"] = distinid;
            dr["AGENT_CITY_ID"] = cityid;
            dr["AGENT_COUNTRY_ID"] = countryid;
            dr["CUSTOMER_BASEINFO_MOBILE"] = mobile;
            dr["CUSTOMER_BASEINFO_PHONE"] = phone;
            dr["CUSTOMER_BASEINFO_QQ"] = qq;
            dr["CUSTOMER_WECHAT_NO"] = wechat;


            dr["DOCUMENT_IMAGE"] = identityCard;

            dr["CUSTOMER_CREDENTIALS_TYPE"] = credentialsType;
            dr["CUSTOMER_BASEINFO_NAME"] = realName;
            dr["CUSTOMER_CREDENTIALS_NO"] = credentialsNo;
            dr["CUSTOMER_BANK_TYPE"] = bankType;
            dr["CUSTOMER_BANK_ACCOUNT"] = bankAccount;

            dr["BASEINFO_IS_DELETED"] = 0;
            dr["BASEINFO_IS_DISPLAY"] = 1;

            ds.Tables[0].Rows.Add(dr);
            ds.Tables[0].TableName = this.TableName;
            this.Update(ds);

            return new string[] { "TRUE", "添加成功" };
        }


        #region 修改游客信息
        /// <summary>
        /// 修改游客信息
        /// </summary>
        /// <param name="cusid">游客ID</param>
        /// <param name="nickname">游客昵称</param>
        /// <param name="picture">游客头像</param>
        /// <param name="sex">性别</param>
        /// <param name="birth">生日</param>
        /// <param name="distinid">目的地编号</param>
        /// <param name="cityid">所在城市编号</param>
        /// <param name="countryid">国家编号</param>
        /// <param name="mobile">移动电话</param>
        /// <param name="phone">固定电话</param>
        /// <param name="qq">qq</param>
        /// <param name="wechat">微信</param>
        /// <param name="email">邮箱</param>
        /// <returns></returns>
        public string[] UpdateCustomer(string cusid, string nickname, string picture, string sex, string birth, string distinid, string cityid, string countryid, string mobile, string phone, string qq, string wechat, string email)
        {
            #region 基本验证
            if (!string.IsNullOrEmpty(email) && !CommValiCollection.IsEmail(email))
            {
                return new string[] { "FALSE", "用户邮箱格式错误" };
            }
            if (!string.IsNullOrEmpty(qq) && !CommValiCollection.IsQQ(qq))
            {
                return new string[] { "FALSE", "QQ只能是以1-9开头的4至12位数字" };
            }
            if (!string.IsNullOrEmpty(birth) && !CommValiCollection.IsDate(birth))
            {
                return new string[] { "FALSE", "生日日期格式错误" };
            }
            #endregion
            #region 修改信息
            //修改用户基本信息
            DataSet ds = SelectCustomerById(cusid);
            if (ds.Tables[0].Rows.Count < 0)
            {
                return new string[] { "FALSE", "该用户不存在" };
            }
            DataRow dr = ds.Tables[0].Rows[0];
            dr["CUSTOMER_BASEINFO_GENDER"] = sex;
            if (!string.IsNullOrEmpty(birth))
            {
                dr["CUSTOMER_BASEINFO_BIRTH"] = birth;
            }
            else
            {
                dr["CUSTOMER_BASEINFO_BIRTH"] = DBNull.Value;
            }

            dr["CUSTOMER_DISTINATION_ID"] = distinid;
            dr["CUSTOMER_CITY_ID"] = cityid;
            dr["CUSTOMER_COUNTRY_ID"] = countryid;
            dr["CUSTOMER_BASEINFO_MOBILE"] = mobile;
            dr["CUSTOMER_BASEINFO_PHONE"] = phone;
            dr["CUSTOMER_BASEINFO_QQ"] = qq;
            dr["CUSTOMER_WECHAT_NO"] = wechat;
            dr["CUSTOMER_BASEINFO_EMAIL"] = email;
            this.Update(ds);

            //修改用户注册信息
            using (CBizCustomerRegister objCBizCustomerRegister = new CBizCustomerRegister())
            {
                DataSet ds1 = objCBizCustomerRegister.SelectCustomerByRegisterId(cusid);
                if (ds1.Tables[0].Rows.Count <= 0)
                {
                    return new string[] { "FALSE", "该用户不存在" };
                }
                DataSet dsName = objCBizCustomerRegister.IsNickNameUnique(nickname, cusid);
                if (dsName.Tables[0].Rows.Count > 0)
                {
                    return new string[] { "FALSE", "该昵称已存在" };
                }
                ds1.Tables[0].Rows[0]["CUSTOMER_NICK"] = nickname;
                ds1.Tables[0].Rows[0]["CUSTOMER_DEFAULT_PIC"] = picture;
                objCBizCustomerRegister.Update(ds1);
            }
            #endregion
            return new string[] { "TRUE", "修改成功" };
        }


        #endregion

        #region 游客详情
        /// <summary>
        /// 查询游客详细信息
        /// </summary>
        /// <param name="djkId">游客ID</param>
        /// <returns>CUSTOMER_REGISTER_ID:游客ID,CUSTOMER_NICK：用户名称，CUSTOMER_DEFAULT_PIC：用户头像，CUSTOMER_BASEINFO_GENDER：性别，CUSTOMER_BASEINFO_BIRTH：生日，CUSTOMER_DISTINATION_ID：所属地区编号，CUSTOMER_CITY_ID：用户城市编号，CUSTOMER_COUNTRY_ID：用户国家编号，CUSTOMER_BASEINFO_MOBILE：用户移动电话，CUSTOMER_BASEINFO_PHONE：用户固定电话，CUSTOMER_BASEINFO_QQ：QQ,CUSTOMER_WECHAT_NO:微信，CUSTOMER_BASEINFO_EMAIL：Email，COUNTRYNAME：所在国家，CITYNAME：所在城市，DISTINANAME：目的地</returns>
        public DataSet GetVisitorByIds(string strId)
        {
            if (string.IsNullOrEmpty(strId))
            {
                return null;
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("STRID", ParameterDirection.Input, EDbType.String, 36, strId.Replace("'", "").Replace(",", "','")));
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT T2.*,C.COUNTRY_CITY_NME DISTINANAME FROM
    (SELECT T1.*,B.COUNTRY_CITY_NME CITYNAME FROM 
    (SELECT T.*,A.COUNTRY_CITY_NME COUNTRYNAME FROM
    (SELECT B.CUSTOMER_REGISTER_ID,B.CUSTOMER_NICK,B.CUSTOMER_DEFAULT_PIC,
    A.CUSTOMER_BASEINFO_GENDER,A.CUSTOMER_BASEINFO_BIRTH,
    A.CUSTOMER_DISTINATION_ID,A.CUSTOMER_CITY_ID,A.CUSTOMER_COUNTRY_ID,
    A.CUSTOMER_BASEINFO_MOBILE,A.CUSTOMER_BASEINFO_PHONE,
    A.CUSTOMER_BASEINFO_QQ,A.CUSTOMER_WECHAT_NO,A.CUSTOMER_BASEINFO_EMAIL
    FROM DJK_CUSTOMER_BASEINFO A
    INNER JOIN DJK_CUSTOMER_REGISTER B
    ON A.CUSTOMER_BASEINFO_ID=B.CUSTOMER_REGISTER_ID
    WHERE A.BASEINFO_IS_DELETED=0 AND A.BASEINFO_IS_DISPLAY=1 AND A.CUSTOMER_BASEINFO_ID=@STRID) T
    LEFT JOIN DJK_COUNTRY_CITY A 
    ON T.CUSTOMER_COUNTRY_ID=A.COUNTRY_CITY_ID) T1
    LEFT JOIN DJK_COUNTRY_CITY B
    ON T1.CUSTOMER_CITY_ID=B.COUNTRY_CITY_ID) T2
    LEFT JOIN DJK_COUNTRY_CITY C
    ON T2.CUSTOMER_DISTINATION_ID=C.COUNTRY_CITY_ID", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }
        #endregion

        #region 游客基本信息
        /// <summary>
        /// 查询游客信息
        /// </summary>
        /// <param name="djkId">游客ID</param>
        /// <returns>CUSTOMER_BASEINFO_ID:游客ID,CUSTOMER_BASEINFO_GENDER：性别，CUSTOMER_BASEINFO_BIRTH：生日，CUSTOMER_DISTINATION_ID：所属地区编号，CUSTOMER_CITY_ID：用户城市编号，CUSTOMER_COUNTRY_ID：用户国家编号，CUSTOMER_BASEINFO_MOBILE：用户移动电话，CUSTOMER_BASEINFO_PHONE：用户固定电话，CUSTOMER_BASEINFO_QQ：QQ,CUSTOMER_WECHAT_NO:微信，CUSTOMER_BASEINFO_EMAIL：Email</returns>
        public DataSet SelectCustomerById(string cusId)
        {
            if (string.IsNullOrEmpty(cusId))
            {
                return null;
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("CUSID", ParameterDirection.Input, EDbType.String, 36, cusId.Replace("'", "").Replace(",", "','")));
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT CUSTOMER_BASEINFO_ID,CUSTOMER_BASEINFO_GENDER,
CUSTOMER_BASEINFO_BIRTH,CUSTOMER_BASEINFO_INTRO,CUSTOMER_CREDENTIALS_TYPE,CUSTOMER_CREDENTIALS_NO,
CUSTOMER_DISTINATION_ID,CUSTOMER_CITY_ID,CUSTOMER_BANK_ACCOUNT,CUSTOMER_BANK_TYPE,
CUSTOMER_COUNTRY_ID,CUSTOMER_BASEINFO_MOBILE,CUSTOMER_BASEINFO_NAME,
CUSTOMER_BASEINFO_PHONE,CUSTOMER_BASEINFO_QQ,
CUSTOMER_WECHAT_NO,CUSTOMER_BASEINFO_EMAIL,
AGENT_DISTINATION_ID,AGENT_CITY_ID,AGENT_COUNTRY_ID,DOCUMENT_IMAGE,CUSTOMER_SERVICE_AREA
    FROM DJK_CUSTOMER_BASEINFO WHERE CUSTOMER_BASEINFO_ID=@CUSID", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        public DataSet SelectUserEmail(string account)
        {
            if (string.IsNullOrEmpty(account))
            {
                return null;
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("ACCOUNT", ParameterDirection.Input, EDbType.String, 36, account.Replace("'", "").Replace(",", "','")));
            DataSet ds = this.DataObj.QueryBySQL(@"select a.CUSTOMER_BASEINFO_EMAIL from DJK_CUSTOMER_BASEINFO a,DJK_CUSTOMER_REGISTER b WHERE a.CUSTOMER_BASEINFO_ID=b.CUSTOMER_REGISTER_ID and b.CUSTOMER_REGISTER_ACCOUNT=@ACCOUNT", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }
        #endregion


        #region 绑定银行及支付宝信息
        public string BindBankInfo(string bankId, string busername, string baccount, string bcomnme, bool isModifyBank)
        {
            string resultStr = string.Empty;

            if (string.IsNullOrEmpty(bankId))
            {
                resultStr = @"ShowErrMsg(""selBankList"", ""notice-msg-bank"", ""请选择银行账户开户行"");";
                return resultStr;
            }

            if (string.IsNullOrEmpty(busername))
            {
                resultStr = @"ShowErrMsg(""txtBankUserNme"", ""notice-msg-username"", ""银行账户用户名不能为空"");";
                return resultStr;
            }

            if (string.IsNullOrEmpty(baccount))
            {
                resultStr = @"ShowErrMsg(""txtBankAccount"", ""notice-msg-bankaccount"", ""银行账户不能为空"");";
                return resultStr;
            }

            if (string.IsNullOrEmpty(bcomnme))
            {
                resultStr = @"ShowErrMsg(""txtBankComNme"", ""notice-msg-comnme"", ""开户行全称不能为空"");";
                return resultStr;
            }

            DataSet ds = this.DataObj.QueryBySQL(@"SELECT * FROM DJK_CUSTOMER_BASEINFO WHERE CUSTOMER_BASEINFO_ID='" + msBsc.SvRef.UserInfo.Operator + "'");
            ds.Tables[0].TableName = this.TableName;

            if (ds == null || ds.Tables[0].Rows.Count <= 0)
            {
                resultStr = @"alert(用户信息有误，不能进行绑定)";
                return resultStr;
            }

            ds.Tables[0].Rows[0]["CUSTOMER_BANK_TYPE"] = bankId;
            ds.Tables[0].Rows[0]["CUSTOMER_BANK_ACCOUNT"] = baccount;
            ds.Tables[0].Rows[0]["CUSTOMER_BANK_NAME"] = bcomnme;
            ds.Tables[0].Rows[0]["CUSTOMER_ACCOUNT_NAME"] = busername;

            if (isModifyBank)
            {
                ds.Tables[0].Rows[0]["CUSTOMER_LAST_MDBANKDT"] = this.dtCurrDateTime;
            }
            else
            {
                ds.Tables[0].Rows[0]["CUSTOMER_FIRST_BINDBANKDT"] = this.dtCurrDateTime;
                ds.Tables[0].Rows[0]["CUSTOMER_LAST_MDBANKDT"] = this.dtCurrDateTime;
            }
            this.Update(ds);

            return resultStr;
        }

        public string BindAliPayInfo(string aliPayAccount, bool isModifyAlipay)
        {
            string resultStr = string.Empty;

            if (string.IsNullOrEmpty(aliPayAccount))
            {
                resultStr = @"ShowErrMsg(""txtAlipayAccount"", ""notice-msg-aliaccount"", ""支付宝账号不能为空"");";
                return resultStr;
            }


            DataSet ds = this.DataObj.QueryBySQL(@"SELECT * FROM DJK_CUSTOMER_BASEINFO WHERE CUSTOMER_BASEINFO_ID='" + msBsc.SvRef.UserInfo.Operator + "'");
            ds.Tables[0].TableName = this.TableName;

            if (ds == null || ds.Tables[0].Rows.Count <= 0)
            {
                resultStr = @"alert(""用户信息有误，不能进行绑定"")";
                return resultStr;
            }

            ds.Tables[0].Rows[0]["CUSTOMER_ALIPAY_ACCOUNT"] = aliPayAccount;
            if (isModifyAlipay)
            {
                ds.Tables[0].Rows[0]["CUSTOMER_LAST_MDALIPAYDT"] = this.dtCurrDateTime;
            }
            else
            {
                ds.Tables[0].Rows[0]["CUSTOMER_FIRST_BINDALIPAYDT"] = this.dtCurrDateTime;
                ds.Tables[0].Rows[0]["CUSTOMER_LAST_MDALIPAYDT"] = this.dtCurrDateTime;

                Random rd = new Random();
                int rdResult = rd.Next(1, 101);
                decimal money = rdResult * 0.01M;

                ds.Tables[0].Rows[0]["SYS_FOR_CREFY"] = money;
                ds.Tables[0].Rows[0]["CUSTOMER_CREFY_STATUS"] = (int)msBsc.AppLogic.DataAlc.CrefEnum.NoCref;
            }
            this.Update(ds);

            return resultStr;
        }
        #endregion

        /// <summary>
        /// 获取用户账户中心信息
        /// </summary>
        /// <returns></returns>
        public DataSet GetUserAccountInfo()
        {
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT CUSTOMER_DRAWALS_ACCOUNT,CUSTOMER_SECDEP_ACCOUNT,CUSTOMER_LAST_DRAWALSDT FROM DJK_CUSTOMER_BASEINFO WHERE CUSTOMER_BASEINFO_ID='" + msBsc.SvRef.UserInfo.Operator + "'");

            return ds;
        }
        /// <summary>
        /// 获取用户账户中心信息
        /// </summary>
        /// <returns></returns>
        public DataSet GetUserAccountInfo(string userid)
        {
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT CUSTOMER_DRAWALS_ACCOUNT,CUSTOMER_SECDEP_ACCOUNT,CUSTOMER_LAST_DRAWALSDT FROM DJK_CUSTOMER_BASEINFO WHERE CUSTOMER_BASEINFO_ID='" + userid + "'");

            return ds;
        }
        /// <summary>
        /// 判断用户是否绑定了提现账户
        /// </summary>
        /// <returns></returns>
        public string IsBindDrawalsAccount()
        {
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT * FROM DJK_CUSTOMER_BASEINFO WHERE CUSTOMER_BASEINFO_ID='" + msBsc.SvRef.UserInfo.Operator + "'");

            if (ds == null || ds.Tables[0].Rows.Count <= 0)
            {
                return "NOUSER";
            }

            if (ds.Tables[0].Rows[0]["CUSTOMER_ALIPAY_ACCOUNT"] == DBNull.Value
                && ds.Tables[0].Rows[0]["CUSTOMER_BANK_ACCOUNT"] == DBNull.Value)
            {
                return "NOACCOUNNT";
            }

            return "OK";
        }

        /// <summary>
        /// 获取代理区域
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        /// Author:任延华
        /// Creation date:2014-9-1
        public DataSet GetProxyDestin(string userid)
        {
            if (string.IsNullOrEmpty(userid))
            {
                return null;
            }
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT AGENT_DISTINATION_ID,AGENT_CITY_ID,AGENT_COUNTRY_ID FROM DJK_CUSTOMER_BASEINFO WHERE CUSTOMER_BASEINFO_ID=(
SELECT TOP 1 FACCOUNT_ID FROM DJK_CUSTOMER_REGISTER WHERE CUSTOMER_REGISTER_ID='" + userid + "')");
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        #region 获取用户银行及支付宝绑定信息
        public DataSet GetAliPayAndBank()
        {
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT T.*,B.BANK_NME FROM(SELECT 
                                                    A.*
                                                    FROM DJK_CUSTOMER_BASEINFO A 
                                    WHERE A.CUSTOMER_BASEINFO_ID='" + msBsc.SvRef.UserInfo.Operator + "') T LEFT JOIN BSE_BANK B ON T.CUSTOMER_BANK_TYPE=B.BANK_ID");
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }
        #endregion

        #region 提现申请处理
        /// <summary>
        /// 申请提现处理
        /// </summary>
        /// <param name="dBalance">提现金额</param>
        /// <param name="applyType">提现方式</param>
        /// <returns>处理结果：OK</returns>
        public string ApplyDrawals(decimal dBalance, string applyType)
        {
            System.Transactions.TransactionOptions transactionOption = new System.Transactions.TransactionOptions();
            transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
            transactionOption.Timeout = new TimeSpan(0, 10, 0);
            using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOption))
            {
                using (Epm.AppLogic.Framework.CDbAccess oacc = new Epm.AppLogic.Framework.CDbAccess())
                {
                    #region 验证账户信息
                    DataSet baseDs = GetAliPayAndBank();
                    if (applyType == "1"
                && (baseDs.Tables[0].Rows[0]["CUSTOMER_ALIPAY_ACCOUNT"] == DBNull.Value
                     || string.IsNullOrEmpty(baseDs.Tables[0].Rows[0]["CUSTOMER_ALIPAY_ACCOUNT"].ToString())))
                    {
                        return "当前账户暂未绑定支付宝账户，不能通过支付宝账户进行提现";
                    }
                    if (applyType == "2"
               && (baseDs.Tables[0].Rows[0]["CUSTOMER_BANK_ACCOUNT"] == DBNull.Value
                   || string.IsNullOrEmpty(baseDs.Tables[0].Rows[0]["CUSTOMER_BANK_ACCOUNT"].ToString())))
                    {
                        return "当前账户暂未绑定银行账户，不能通过银行账户进行提现";
                    }

                    if (Convert.ToDecimal(baseDs.Tables[0].Rows[0]["CUSTOMER_DRAWALS_ACCOUNT"]) <= 0)
                    {
                        return "当前账户没有可提现金额";
                    }
                    if (Convert.ToDecimal(baseDs.Tables[0].Rows[0]["CUSTOMER_DRAWALS_ACCOUNT"]) - dBalance < 0)
                    {
                        return "当前账户余额不足";
                    }
                    #endregion

                    #region 修改账户信息
                    baseDs.Tables[0].Rows[0]["CUSTOMER_DRAWALS_ACCOUNT"] = Convert.ToDecimal(baseDs.Tables[0].Rows[0]["CUSTOMER_DRAWALS_ACCOUNT"]) - dBalance;

                    DateTime currentTime = this.dtCurrDateTime;
                    baseDs.Tables[0].Rows[0]["CUSTOMER_LAST_DRAWALSDT"] = currentTime;
                    #endregion

                    #region 生成申请记录
                    DataSet drawalsDs = new CDmDjkDrawalsRecord();
                    DataRow drawalsDr = drawalsDs.Tables[0].NewRow();

                    drawalsDr["DRAWALS_RECORD_ID"] = this.DataObj.NewID();
                    drawalsDr["APPLIER_ID"] = msBsc.SvRef.UserInfo.Operator;
                    drawalsDr["DRAWALS_BALANCE"] = dBalance;
                    drawalsDr["DRAWALS_RECORD_STATUS"] = (int)msBsc.AppLogic.DataAlc.cls.CommonEnum.DrawalsEnum.waiting;
                    drawalsDr["DRAWALS_APPLY_DT"] = currentTime;
                    drawalsDr["DRAWALS_PAY_DT"] = DBNull.Value;
                    drawalsDr["DRAWALS_IS_FINISHED"] = 0;
                    drawalsDr["CUSTOMER_ACCOUNT_TYPE"] = int.Parse(applyType);
                    drawalsDr["CUSTOMER_ACCOUNT_NAME"] = baseDs.Tables[0].Rows[0]["CUSTOMER_BANK_TYPE"];
                    drawalsDr["DRAWALS_CUST_ACCOUNT"] = applyType == "1" ? baseDs.Tables[0].Rows[0]["CUSTOMER_ALIPAY_ACCOUNT"] : baseDs.Tables[0].Rows[0]["CUSTOMER_BANK_ACCOUNT"];
                    drawalsDr["DRAWALS_CUST_IP"] = msBsc.Cls.CommValiCollection.GetIp();
                    drawalsDr["DRAWALS_CUST_CONTENT"] = DBNull.Value;
                    drawalsDr["DRAVALS_IS_DELETED"] = 0;
                    drawalsDr["DRAVALS_RMK"] = DBNull.Value;

                    drawalsDs.Tables[0].Rows.Add(drawalsDr);
                    #endregion

                    #region 生成交易记录
                    using (CBizDjkChargeTradingLog objCBizDjkChargeTradingLog = new CBizDjkChargeTradingLog())
                    {
                        objCBizDjkChargeTradingLog.AddNewRow(msBsc.SvRef.UserInfo.Operator, msBsc.SvRef.UserInfo.OperatorName, "收入", msBsc.SvRef.UserInfo.OperType, drawalsDr["DRAWALS_RECORD_ID"].ToString(), msBsc.SvRef.UserInfo.OperType == "1" ? "游客提现" : "商户提现", "提现", "system", "地接客平台", "在线支付", drawalsDr["DRAWALS_BALANCE"].ToString(), "待支付", "通过申请提现的方式，将用户提现账户中的余额进行提现", msBsc.SvRef.UserInfo.Operator, baseDs.Tables[0].Rows[0]["CUSTOMER_ALIPAY_ACCOUNT"].ToString());
                    }
                    #endregion

                    this.Update(baseDs);

                    new CBizDrawalsRecord().Update(drawalsDs);

                    ts.Complete();

                }
            }
            return "OK";
        }
        #endregion

        #region 银行及支付宝账户认证
        //public void SetCrefyInfo(bool isCrefSuccess)
        //{
        //    if (isCrefSuccess)
        //    {

        //    }
        //}

        /// <summary>
        /// 查询用户支付宝认证信息
        /// </summary>
        /// <param name="crfCondition">查询条件</param>
        /// <returns></returns>
        public DataSet GetUserAccountByAliCrefy(string crfCondition, string userType)
        {
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("accountstatus", ParameterDirection.Input, EDbType.Integer, 2, crfCondition));
            parmCollection.Add(new CDbParm("usertype", ParameterDirection.Input, EDbType.Integer, 2, userType));

            DataSet ds = this.DataObj.QueryBySP("DJK_SELECT_ACCOUNT_FOR_CREFY", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }
        #endregion

        #region 添加代理下地接客信息基本信息
        /// <summary>
        /// 为代理下地接客添加基本信息
        /// </summary>
        /// <param name="id">编号</param>
        /// <param name="djkName">姓名</param>
        /// <param name="countryId">国家编号</param>
        /// <param name="cityId">城市编号</param>
        /// <param name="destinationId">目的地编号</param>
        /// <param name="telPhone">电话</param>
        /// <param name="serviceArea">服务区域</param>
        /// <param name="tencentQQ">腾讯QQ</param>
        /// <param name="weChatNo">微信号码</param>
        /// Author:刘魏
        /// Creation date:2015-9-9 11:00
        public void AddAgentDjackBase(string id, string djkName, string countryId, string cityId, string destinationId, string telPhone, string serviceArea, string tencentQQ, string weChatNo)
        {
            DataSet ds = new CDmDjkCustomerBaseInfo();
            DataRow dr = ds.Tables[0].NewRow();

            dr["CUSTOMER_BASEINFO_ID"] = id;
            dr["CUSTOMER_BASEINFO_NAME"] = djkName;
            dr["CUSTOMER_DISTINATION_ID"] = destinationId;
            dr["CUSTOMER_CITY_ID"] = cityId;
            dr["CUSTOMER_COUNTRY_ID"] = countryId;
            dr["CUSTOMER_BASEINFO_MOBILE"] = telPhone;
            dr["CUSTOMER_BASEINFO_QQ"] = tencentQQ;
            dr["CUSTOMER_WECHAT_NO"] = weChatNo;
            dr["CUSTOMER_SERVICE_AREA"] = serviceArea;
            dr["BASEINFO_IS_DELETED"] = 0;
            dr["BASEINFO_IS_DISPLAY"] = 1;
            dr["CUSTOMER_BASEINFO_GENDER"] = "F";
            dr["IS_DRIVING_LICENSE"] = 0;
            dr["IS_QUALIFICATION_CERTIFICATE"] = 0;
            dr["IS_XINGSI_LICENSE"] = 0;
            dr["IS_TRANSPORT_CERTIFICATE"] = 0;
            dr["IS_RECORD_CARD"] = 0;

            ds.Tables[0].Rows.Add(dr);

            this.Update(ds);
        }
        #endregion


        /// <summary>
        /// 获取 区域代理详细信息
        /// </summary>
        /// <param name="userid">用户id</param>
        /// <returns></returns>
        /// Author:蒲崇彬
        /// Creation date:2015-9-1 17:52
        public DataTable GetBaseInfoByID(string userid)
        {

            if (string.IsNullOrEmpty(userid))
            {
                return null;
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("USERID", ParameterDirection.Input, EDbType.String, 36, userid));
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT R.CUSTOMER_REGISTER_ID,R.CUSTOMER_DEFAULT_PIC,B.CUSTOMER_BASEINFO_NAME,
B.CUSTOMER_BASEINFO_GENDER,B.CUSTOMER_CREDENTIALS_TYPE,
B.CUSTOMER_CREDENTIALS_NO,B.CUSTOMER_BASEINFO_BIRTH,B.CUSTOMER_BASEINFO_PHONE,
B.CUSTOMER_BASEINFO_MOBILE,B.CUSTOMER_BASEINFO_QQ,B.CUSTOMER_WECHAT_NO,B.CUSTOMER_BANK_ACCOUNT,
B.CUSTOMER_BANK_TYPE,B.DOCUMENT_IMAGE,
B.AGENT_DISTINATION_ID,
B.AGENT_CITY_ID,B.AGENT_COUNTRY_ID
 FROM DJK_CUSTOMER_REGISTER(NOLOCK) R  
LEFT JOIN DJK_CUSTOMER_BASEINFO(NOLOCK) B
ON R.CUSTOMER_REGISTER_ID=B.CUSTOMER_BASEINFO_ID WHERE R.CUSTOMER_ACCOUNT_TYPE=5 AND CUSTOMER_BASEINFO_ID=@USERID", parmCollection);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                return ds.Tables[0];
            }

            return null;
        }



        /// <summary>
        /// 区域代理 修改
        /// </summary>
        /// <param name="cusid">用户ID</param>
        /// <param name="identityCard">身份证 照片</param>
        /// <param name="realName">真实姓名</param>
        /// <param name="credentialsNo">身份证号码</param>
        /// <param name="sex">性别</param>
        /// <param name="birth">生日</param>
        /// <param name="distinid">代理 地区（地区）</param>
        /// <param name="cityid">代理 地区（城市）</param>
        /// <param name="countryid">代理 地区（国）</param>
        /// <param name="mobile">移动电话</param>
        /// <param name="phone">固定电话</param>
        /// <param name="qq">qq</param>
        /// <param name="wechat">微信</param>
        /// <param name="bankType">银行类型</param>
        /// <param name="bankAccount">银行帐号</param>
        /// <param name="credentialsType">证件类型</param>
        /// <returns>string[]</returns>
        /// Author:蒲崇彬
        /// Creation date:2015-8-31 17:59
        public string[] UpdateCustomerBaseInfo(string cusid, string identityCard, string realName, string credentialsNo, string sex, string birth, string distinid, string cityid, string countryid, string mobile, string phone, string qq, string wechat, string bankType, string bankAccount, string credentialsType)
        {
            if (!string.IsNullOrEmpty(qq) && !CommValiCollection.IsQQ(qq))
            {
                return new string[] { "FALSE", "QQ只能是以1-9开头的4至12位数字" };
            }
            if (!string.IsNullOrEmpty(birth) && !CommValiCollection.IsDate(birth))
            {
                return new string[] { "FALSE", "生日日期格式错误" };
            }

            DataSet ds = SelectCustomerById(cusid);
            if (ds.Tables[0].Rows.Count < 0)
            {
                return new string[] { "FALSE", "该用户不存在" };
            }
            DataRow dr = ds.Tables[0].Rows[0];

            //修改区域 代理基本信息
            dr["CUSTOMER_BASEINFO_GENDER"] = sex;

            if (!string.IsNullOrEmpty(birth))
            {
                dr["CUSTOMER_BASEINFO_BIRTH"] = birth;
            }
            else
            {
                dr["CUSTOMER_BASEINFO_BIRTH"] = DBNull.Value;
            }
            dr["CUSTOMER_BASEINFO_ID"] = cusid;
            dr["AGENT_DISTINATION_ID"] = distinid;
            dr["AGENT_CITY_ID"] = cityid;
            dr["AGENT_COUNTRY_ID"] = countryid;

            dr["CUSTOMER_BASEINFO_MOBILE"] = mobile;
            dr["CUSTOMER_BASEINFO_PHONE"] = phone;
            dr["CUSTOMER_BASEINFO_QQ"] = qq;
            dr["CUSTOMER_WECHAT_NO"] = wechat;


            dr["DOCUMENT_IMAGE"] = identityCard;

            dr["CUSTOMER_CREDENTIALS_TYPE"] = credentialsType;
            dr["CUSTOMER_BASEINFO_NAME"] = realName;
            dr["CUSTOMER_CREDENTIALS_NO"] = credentialsNo;
            dr["CUSTOMER_BANK_TYPE"] = bankType;
            dr["CUSTOMER_BANK_ACCOUNT"] = bankAccount;

            ds.Tables[0].TableName = this.TableName;
            this.Update(ds);

            return new string[] { "TRUE", "修改成功" };
        }


        /// <summary>
        /// 获取区域代理 注册列表
        /// </summary>
        /// <param name="countryid">国家</param>
        /// <param name="cityid">城市</param>
        /// <param name="distinid">地区</param>
        /// <param name="mobile">电话</param>
        /// <param name="realName">真实姓名</param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns>dataSet</returns>
        /// Author:蒲崇彬
        /// Creation date:2015-9-6 11:14
        public DataSet GetBaseInfoPageList(string countryid, string cityid, string distinid, string mobile, string realName, int pageSize, int pageIndex)
        {

            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("routecountry", ParameterDirection.Input, EDbType.String, 36, countryid));
            parmCollection.Add(new CDbParm("province", ParameterDirection.Input, EDbType.String, 36, cityid));
            parmCollection.Add(new CDbParm("area", ParameterDirection.Input, EDbType.String, 36, distinid));

            parmCollection.Add(new CDbParm("mobile", ParameterDirection.Input, EDbType.String, 20, mobile));
            parmCollection.Add(new CDbParm("name", ParameterDirection.Input, EDbType.String, 50, realName));

            parmCollection.Add(new CDbParm("pagesize", ParameterDirection.Input, EDbType.Integer, 32, pageSize));
            parmCollection.Add(new CDbParm("pageindex", ParameterDirection.Input, EDbType.Integer, 32, pageIndex));

            return this.DataObj.QueryBySP("DJK_BASEINFO_LIST_VIEW", parmCollection);

        }


        /// <summary>
        /// 修改 基本信息，证件是否添加
        /// </summary>
        /// <param name="keys">
        /// IS_DRIVING_LICENSE(驾驶证)
        /// IS_QUALIFICATION_CERTIFICATE(资格证)
        /// IS_XINGSI_LICENSE(行驶证)
        /// IS_TRANSPORT_CERTIFICATE(运输证)
        /// IS_RECORD_CARD(备案证)</param>
        /// <param name="userid"></param>
        /// <param name="status"></param>
        /// <returns>string</returns>
        /// Author:蒲崇彬
        /// Creation date:2015-9-9 10:20
        public string UpdateCertificatesStatus(string[] keys, string userid, bool status)
        {

            if (keys.Length < 1)
            {
                return "请输入要修改的证件";
            }

            if (string.IsNullOrEmpty(userid))
            {
                return "该用户不存在";
            }

            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("USERID", ParameterDirection.Input, EDbType.String, 36, userid));
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT * FROM [dbo].[DJK_CUSTOMER_BASEINFO] WHERE CUSTOMER_BASEINFO_ID=@USERID", parmCollection);

            if (ds == null || ds.Tables[0].Rows.Count < 1)
            {
                return "数据不存在";
            }

            foreach (var item in keys)
            {
                ds.Tables[0].Rows[0][item] = status;
            }

            ds.Tables[0].TableName = this.TableName;
            this.Update(ds);
            return "true";
        }

        /// <summary>
        /// 平台查询地接客信息
        /// </summary>
        /// <param name="djkName">地接客姓名</param>
        /// <param name="djkPhone">地接客电话</param>
        /// <param name="agentName">代理姓名</param>
        /// <param name="agentPhone">代理电话</param>
        /// <param name="countryid">国家编号</param>
        /// <param name="cityid">城市编号</param>
        /// <param name="desid">目的地编号</param>
        /// <param name="isDle">是否已删除</param>
        /// <returns></returns>
        /// Author:刘魏
        /// Creation date:2015-9-9 11:11
        public DataSet GetAgentDjackInfo(string djkName, string djkPhone, string agentName, string agentPhone, string countryid, string cityid, string desid, bool isDle)
        {
            djkName = string.IsNullOrWhiteSpace(djkName) ? "" : "%" + djkName + "%";
            djkPhone = string.IsNullOrWhiteSpace(djkPhone) ? "" : "%" + djkPhone + "%";
            agentName = string.IsNullOrWhiteSpace(agentName) ? "" : "%" + agentName + "%";
            agentPhone = string.IsNullOrWhiteSpace(agentPhone) ? "" : "%" + agentPhone + "%";

            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("djackname", ParameterDirection.Input, EDbType.String, 30, djkName));
            parmCollection.Add(new CDbParm("djackphone", ParameterDirection.Input, EDbType.String, 20, djkPhone));
            parmCollection.Add(new CDbParm("agentname", ParameterDirection.Input, EDbType.String, 30, agentName));
            parmCollection.Add(new CDbParm("agentphone", ParameterDirection.Input, EDbType.String, 20, agentPhone));
            parmCollection.Add(new CDbParm("desid", ParameterDirection.Input, EDbType.String, 36, desid));
            parmCollection.Add(new CDbParm("cityid", ParameterDirection.Input, EDbType.String, 36, cityid));
            parmCollection.Add(new CDbParm("countryid", ParameterDirection.Input, EDbType.String, 36, countryid));
            parmCollection.Add(new CDbParm("isdeleted", ParameterDirection.Input, EDbType.Boolean, 1, isDle));

            DataSet ds = this.DataObj.QueryBySP("DJK_SELECT_AGENT_DJACK_FOR_VIEW", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;

        }

        /// <summary>
        /// 删除地接客
        /// </summary>
        /// <param name="djkId">地接客编号</param>
        /// <returns></returns>
        /// Author:刘魏
        /// Creation date:2015-9-10 16:30
        public string[] RemoveAgentDjackInfo(string djkId)
        {
            if (string.IsNullOrWhiteSpace(djkId))
            {
                return new string[] { "FALSE", "该地接客不存在" };
            }
            System.Transactions.TransactionOptions transactionOption = new System.Transactions.TransactionOptions();
            transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
            transactionOption.Timeout = new TimeSpan(0, 10, 0);
            using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOption))
            {
                DataSet ds, ds1, ds2;
                using (CBizCustomerRegister objCBizCustomerRegister = new CBizCustomerRegister())
                {
                    ds = objCBizCustomerRegister.SelectById(djkId);

                    if (ds == null
                    || ds.Tables[0].Rows.Count <= 0)
                    {
                        return new string[] { "FALSE", "该地接客不存在" };
                    }

                    ds1 = SelectById(djkId);

                    if (ds1 != null
                        && ds1.Tables[0].Rows.Count > 0)
                    {
                        ds1.Tables[0].Rows[0]["BASEINFO_IS_DELETED"] = 1;
                        this.Update(ds1);
                    }

                    ds.Tables[0].Rows[0]["ACCOUNT_IS_DELETED"] = 1;
                    objCBizCustomerRegister.Update(ds);

                    using (CBizVehicleInfo objCBizVehicleInfo = new CBizVehicleInfo())
                    {
                        ds2 = objCBizVehicleInfo.GetVehicleForPageByDjkId(100, 1, djkId);

                        if (ds2 != null
                            && ds2.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
                            {
                                ds2.Tables[0].Rows[i]["VEHICLE_IS_DELETED"] = 1;
                            }
                            objCBizVehicleInfo.Update(ds2);
                        }
                    }
                    ts.Complete();
                    return new string[] { "TRUE", "删除成功" };
                }
            }

        }


        /// <summary>
        /// 根据地接客id查询地接客信息
        /// </summary>
        /// <param name="djkId">地接客Id</param>
        /// <returns></returns>
        /// Author:刘魏
        /// Creation date:2015-9-14 9:00
        public DataSet GetAgentDjackDetailById(string djkId)
        {
            if (string.IsNullOrWhiteSpace(djkId))
            {
                return new DataSet();
            }

            DataSet ds;

            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("djkid", ParameterDirection.Input, EDbType.String, 36, djkId));

            ds = this.DataObj.QueryBySQL(@"SELECT 
                                T.*
                                ,B.CUSTOMER_NICK
                                ,B.CUSTOMER_DEFAULT_PIC 
                                ,C.COUNTRY_CITY_NME P_COUNTRY_NAME
                                ,D.COUNTRY_CITY_NME P_CITY_NAME
                                ,E.COUNTRY_CITY_NME P_DISTINATION_NAME
                                FROM (SELECT
                                 A.*
                                 FROM DJK_CUSTOMER_BASEINFO A 
                                 WHERE A.CUSTOMER_BASEINFO_ID=@djkid) T
                                LEFT JOIN DJK_CUSTOMER_REGISTER B ON T.CUSTOMER_BASEINFO_ID=B.CUSTOMER_REGISTER_ID
                                LEFT JOIN DJK_COUNTRY_CITY C ON T.CUSTOMER_COUNTRY_ID=C.COUNTRY_CITY_ID
                                LEFT JOIN DJK_COUNTRY_CITY D ON T.CUSTOMER_CITY_ID=D.COUNTRY_CITY_ID
                                LEFT JOIN DJK_COUNTRY_CITY E ON T.CUSTOMER_DISTINATION_ID=E.COUNTRY_CITY_ID", parmCollection);
            return ds;
        }
    }

    public enum CrefEnum
    {
        /// <summary>
        /// 未认证
        /// </summary>
        NoCref = 1,
        /// <summary>
        /// 已付款
        /// </summary>
        PayMoney = 2,
        /// <summary>
        /// 通过认证
        /// </summary>
        PassCref = 3,
        /// <summary>
        /// 认证失败
        /// </summary>
        FialedCref = 4
    }
}
